package com.liu.springmvc.handler;

import org.springframework.core.Ordered;

import javax.servlet.http.HttpServletRequest;

/**
 * @author LIU
 * @version 1.0
 * @description TODO
 * @date 2024/1/26 15:05
 */
public abstract class AbstractHandlerMapping implements HandlerMapping, Ordered {
    //　排序
    private int order;


    @Override
    public HandlerExecutionChain getHandler(HttpServletRequest request) {
        Object handler = getHandlerInternal(request);
        if (handler == null){
            return null;
        }

        HandlerExecutionChain executionChain = new HandlerExecutionChain(handler);

        //  @TODO 添加拦截器
        return executionChain ;
    }



    /*
     *  子类实现具体的handler方法
     */
    protected abstract Object getHandlerInternal(HttpServletRequest request);


    public void setOrder(int order) {
        this.order = order;
    }

    @Override
    public int getOrder() {
        return this.order;
    }
}
